package com.fc.backingbeans

import javax.annotation.PostConstruct
import javax.faces.bean.ViewScoped

import org.primefaces.model.chart.MeterGaugeChartModel
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

import com.fc.calculators.BmiCalculator
import com.fc.entities.User
import com.fc.service.UserDetailsService

@Component("accountPanelController")
@ViewScoped
class AccountPanelController {
	private MeterGaugeChartModel meterGaugeModel;

	@Autowired
	private UserDetailsService userDetailsService
	
	@Autowired
	private BmiCalculator bmiCalculator
	
	BigDecimal bmi
	
	public MeterGaugeChartModel getMeterGaugeModel() {
		List<Number> intervals = new ArrayList<Number>(){
			{
				add(20);
				add(26);
				add(31);
				add(50);
			}
		};

		User user = userDetailsService.currentUser
		bmi = bmiCalculator.calculate(user.weight, user.height)
		meterGaugeModel = new MeterGaugeChartModel(bmi, intervals);
	}
}
